import matplotlib.pyplot as plt
import networkx as nx
from matplotlib import rcParams

# 设置字体
rcParams['font.sans-serif'] = ['Microsoft YaHei', 'SimHei', 'Arial Unicode MS', 'sans-serif']
rcParams['axes.unicode_minus'] = False  # 解决负号显示问题

def draw_functional_flowchart():
    G = nx.DiGraph()

    # 添加节点
    G.add_node("用户注册")
    G.add_node("用户登录")
    G.add_node("行程管理")
    G.add_node("目的地管理")
    G.add_node("收藏与分享")

    # 添加边
    G.add_edges_from([
        ("用户注册", "用户登录"),
        ("用户登录", "行程管理"),
        ("用户登录", "目的地管理"),
        ("用户登录", "收藏与分享"),
        ("行程管理", "收藏与分享"),
        ("目的地管理", "收藏与分享"),
    ])

    pos = nx.spring_layout(G)
    nx.draw(G, pos, with_labels=True, node_size=3000, node_color='lightblue', font_size=10, font_weight='bold', edge_color='gray')
    plt.title('功能需求流程图')
    plt.savefig('functional_flowchart.png')
    plt.show()

if __name__ == "__main__":
    draw_functional_flowchart() 